package accountSer;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class AccountServlet extends HttpServlet {
	public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=utf-8");
		// 1.得到请求参数
		String accountIn = request.getParameter("accountin");
		String accountOut = request.getParameter("accountout");
		double money = Double.parseDouble(request.getParameter("money"));
		// 调用不知所谓的service,将所有动作封装到里面
		AccountService service = new AccountService();
		try {
			service.account(accountIn, accountOut, money);
			response.getWriter().write("转账成功");
		} catch (AccountException e) {
			// TODO Auto-generated catch block
			response.getWriter().write(e.getMessage());
		}
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
}
